#include "client.h"

Client::Client(wstring tag) : _tag(tag) {

}

int Client::Connect(const char* server,int port, const char* app) {
    _server = string(server);
    _port = port;
    _app = string(app);

    _pRtmpClient = shared_ptr<RTMPClientConnection>(new RTMPClientConnection(_tag));
    return _pRtmpClient->Connect(server, port, app, this);
}

void Client::onConnected(RTMPClientConnection* conn) {
    printf("%s\n", __FUNCTION__);
    DWORD id = conn->GetUserData();
	//Log
	printf("-RTMPClientConnection connected [id:%d]\n",id);
    conn->CreateStream(_tag);
}

void Client::onNetStreamCreated(RTMPClientConnection* conn,RTMPClientConnection::NetStream *stream) {
    printf("%s\n", __FUNCTION__);
    stream->Play();
}

void Client::onCommandResponse(RTMPClientConnection* conn,DWORD id,bool isError,AMFData* param) {
    printf("%s\n", __FUNCTION__);
}

void Client::onDisconnected(RTMPClientConnection* conn) {
    printf("%s\n", __FUNCTION__);
}